package net.sshiffon

import groovy.util.GroovyTestCase

class ConnectionSettingTest extends GroovyTestCase {

    void testX() {
    	def x= [ host: 'h' ];
    	def j= new ConnectionSetting();
    	x.each{ k,v -> 
    		j."${k}" = v
    	}
    	assert x.host == j.host
    }

    void testY() {
    	def map1= [ host: 'h' ];
    	def j= new ConnectionSetting(map1);
    	def map2= [:]

    	j.class.fields.each { field ->
    		map2.put( field.name, j."${field.name}" ) 
    	}
    	assert map2 != map1
    }

    void testZ()
	{
    	def map1= [ host: 'h' ];
		def j= new ConnectionSetting(map1);
		def map2= [:]

        //def fields= 
        j.metaClass.properties*.name
        	.findAll{ it != 'property' && it != 'metaClass' }
			.each { map2."$it" = j."$it" }
        
        /*
        def fieldnames= ConnectionSetting.methods.name
        	.findAll{ it =~ /^get[A-Z]/ && it != 'getProperty' && it != 'getMetaClass' }
			.collect{ it[3].toLowerCase()+it[4..-1] }
		*/
        
        def x= j.dump()
        
        println x
        def y= j.inspect()
        println y
//		fields.each { map2.put(it,j."$it") }
		println map2
		//assert map2 == map1
    }
	
}